import axios from "axios";
import { Loading } from "element-ui";
// const apis = {
//   production: "http://222.92.133.154:5912/", //生产环境   线上
//   development: "http://localhost:8080/",
// };
let loadingInstance; //定义全局loading
const instance = axios.create({
  baseURL: "",
});

instance.interceptors.request.use(
  (config) => {
    loadingInstance = Loading.service();  //开启全局loading
    return config;
  },
  (err) => {
    return Promise.reject(err);
  }
);

instance.interceptors.response.use(
  (res) => {
    loadingInstance.close(); //关闭全局loading
    return res;
  },
  (err) => {
    return Promise.reject(err);
  }
);
export default instance;
